/**
 * 
 */
package pt.mleiria.bean;

import java.util.LinkedHashMap;
import java.util.Map;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import pt.mleiria.bo.LivingRoomEJB;
import pt.mleiria.utils.Navigator;

/**
 * @author NB13712
 *
 */
@ManagedBean(name = "livingRoomBean")
@RequestScoped
public class LivingRoomBean extends MasterBean{
	@EJB
	private LivingRoomEJB livingRoomEjb;
	private String currentAlarm;
	private int alarmOption = 2;
	private String musicCollection;
	private String voice;
	private Map<String,Object> alarmOptionValue;
	private Map<String,Object> musicCollectionValue;
	
	public LivingRoomBean() {
		alarmOptionValue = new LinkedHashMap<String,Object>();
		alarmOptionValue.put("Voice", "1"); 
		alarmOptionValue.put("Music", "2");
		musicCollectionValue = new LinkedHashMap<String,Object>();
		musicCollectionValue.put("low rider", "/asas/asa/lowRider.mp3"); 
		musicCollectionValue.put("power of soul", "/asas/asa/power.mp3");
	}
	
	public String getVoice() {
		return voice;
	}


	public void setVoice(String voice) {
		this.voice = voice;
	}

	/**
	 * 
	 * @return
	 */
	public LivingRoomEJB getLivingRoomEjb() {
		return livingRoomEjb;
	}
	/**
	 * 
	 * @return
	 */
	public Map<String, Object> getAlarmOptionValue(){
		return alarmOptionValue;
	}
	
	public Map<String, Object> getMusicCollectionValue() {
		return musicCollectionValue;
	}
	/**
	 * 
	 * @return
	 */
	public int getAlarmOption(){
		return alarmOption;
	}
	/**
	 * 
	 * @param alarmOption
	 */
	public void setAlarmOption(int alarmOption) {
		this.alarmOption = alarmOption;
	}
	/**
	 * 
	 * @return
	 */
	public String getCurrentAlarm() {
		return currentAlarm;
	}
	/**
	 * 
	 * @param currentAlarm
	 */
	public void setCurrentAlarm(String currentAlarm) {
		this.currentAlarm = currentAlarm;
	}
	/**
	 * 
	 * @return
	 */
	public String getMusicCollection() {
		return musicCollection;
	}
	/**
	 * 
	 * @param musicCollection
	 */
	public void setMusicCollection(String musicCollection) {
		this.musicCollection = musicCollection;
	}
	/**
	 * 
	 * @return
	 */
	public String setAlarm(){
		getLogger(LivingRoomBean.class).info("Living Room Bean");
		switch(alarmOption){
		case 1:
			livingRoomEjb.setAlarmWithVoice(currentAlarm, voice);
			break;
		case 2:
			livingRoomEjb.setAlarmWithMusic(currentAlarm, musicCollection);
			break;
		}
		index = Navigator.LivingRoom.getValue();
		return Navigator.LivingRoom.getLnk();
	}
	/**
	 * 
	 * @return
	 */
	public String clearAlarm(){
		livingRoomEjb.powerOffLivingRoom();
		return "clear Alarm";
	}

}
